<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <title></title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">

    <link rel="stylesheet" href="../css/bootstrap.min.css" />

    <script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>

    <script type="text/javascript" src="../js/bootstrap.min.js" ></script>
    <script type="text/javascript" src="../js/jquery.bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/plugins/jquery.form.js"></script>
    <script type="text/javascript" src="../js/plugins/jquery.twbsPagination.min.js"></script>


    <script type="text/javascript">
        function toPage(page) {
            $("#myfrom").attr("action", "selectBidRequest?currPage=" + page+"&bidRequestState="+5);
            $("#myfrom").submit();
        }


        $(function () {

            var currPage = ${pager.currPage};

            var totalPages = ${pager.totalPages};

            if (currPage >= totalPages) {
                $("#next").removeAttr("href");
            }
            if (currPage <= 1) {
                $("#prev").removeAttr("href");
            }



            $(".btn_audit").click(function(){
                var form=$("#editform");
                form.find("[name=bidRequestState]").val($(this).val());
                $("#myModal").modal("hide");
                form.ajaxSubmit(function(data){
                    if(data.success){
                         $.messager.confirm("提示",data.msg,function(){
                             window.location.reload(true);
                         });
                     }else{
                        $.messager.confirm("提示","系统故障，操作失败");
                     }
                });
                return false;
            });


            $(".auditClass").click(function(){
                $("#editform")[0].reset();
                var data=$(this).data("json");
                $("#myModal [name=bidRequestid]").val(data.id);
                $("#myModal [name=username]").html(data.username);
                $("#myModal [name=title]").html(data.title);
                $("#myModal [name=bidRequestAmount]").html(data.bidRequestAmount);
                $("#myModal [name=currentRate]").html(data.currentRate);
                $("#myModal [name=monthes2Return]").html(data.monthes2Return);
                $("#myModal [name=returnType]").html(data.returnType);
                $("#myModal [name=totalRewardAmount]").html(data.totalRewardAmount);

                $("#myModal").modal("show");
            });

        });

    </script>
</head>
<body>


<center>
    <h1>满标2审核</h1>
</center>
<form id="myfrom" action="./select" method="post">

    <center>
        <select name="state">
            <option value="-1">请选择</option>
            <option value="0">申请状态</option>
            <option value="1">审核通过</option>
            <option value="2">审核失败</option>
        </select>
        申请时间<input type="text" name="startDate" /> 到
        <input type="text" name="endDate" />
        <input type="submit" value="查询"/>
        <br/>
        <br />
    </center>
    <table align="center" width="70%" border="1px">
        <tr align="center">
            <td>标题</td>
            <td>借款人</td>
            <td>申请时间</td>
            <td>借款金额（元）</td>
            <td>期限</td>
            <td>利率</td>
            <td>总利息</td>
            <td>状态</td>
            <td></td>
        </tr>
        <c:forEach items="${list}" var="re" varStatus="st">
            <tr align="center"
                    <c:if test="${st.index %2 ==0 }">
                        style="background-color:lightblue"
                    </c:if>
            >
                <td>${re.title}</td>
                <td>${re.createUser.username }</td>
                <td><fmt:formatDate  value="${re.applyTime}" pattern="yyyy-MM-dd"/></td>
                <td>${re.bidRequestAmount}</td>
                <td>${re.monthes2Return}</td>
                <td>${re.currentRate}</td>
                <td>${re.totalRewardAmount}</td>
<%--                $("#myModal [name=id]").val(data.id);
                $("#myModal [name=username]").html(data.username);
                $("#myModal [name=title]").html(data.title);
                $("#myModal [name=bidRequestAmount]").html(data.bidRequestAmount);
                $("#myModal [name=currentRate]").html(data.currentRate);
                $("#myModal [name=monthes2Return]").html(data.monthes2Return);
                $("#myModal [name=returnType]").html(data.returnType);
                $("#myModal [name=totalRewardAmount]").html(data.totalRewardAmount);--%>
                <td>${re.getBidRequestStateDisplay()}</td>
                <td>
                    <c:if test="${re.bidRequestState==4}" var="flag">
                    <a href="javaScript:void(-1)" class="auditClass" data-json='{"id":"${re.bidRequestid}","username":"${re.createUser.username}","title":"${re.title }",
                                "bidRequestAmount":"${re.bidRequestAmount}","currentRate":"${re.currentRate }","monthes2Return":"${re.monthes2Return}",
                                "returnType":"${re.returnType}","totalRewardAmount":"${re.totalRewardAmount}"}' >审核</a>
                    </c:if>
                </td>

            </tr>
        </c:forEach>
    </table>
    <center>
        <a href="javaScript:toPage(1)">首页</a>&nbsp;&nbsp;
        <a id="prev" href="javaScript:toPage(${pager.currPage-1 })">上一页</a>&nbsp;&nbsp;
        <a id="next" href="javaScript:toPage(${pager.currPage+1 })">下一页</a>&nbsp;&nbsp;
        <a href="javaScript:toPage(${pager.totalPages})">尾页</a>&nbsp;&nbsp;
        <span>第${pager.currPage }页/共${pager.totalPages }页</span>
    </center>

</form>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <form class="form-horizontal" id="editform" method="post" action="./doUpdateBidRequest">
                    <fieldset>
                        <div id="legend" class="">
                            <legend>发标前审核</legend>
                        </div>
                        <input type="hidden" name="bidRequestid" value="">
                        <input type="hidden" name="bidRequestState" value="">
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="title">标题</label>
                            <div class="col-sm-6">
                                <label class="form-control" name="title"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="username">借款人</label>
                            <div class="col-sm-6">
                                <label class="form-control" name="username"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="bidrequestAmount">借款金额(元)</label>
                            <div class="col-sm-6">
                                <label class="form-control" name="bidRequestAmount"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="monthes2Return">期限</label>
                            <div class="col-sm-6">
                                <label class="form-control" name="monthes2Return"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="currentRate">还款方式</label>
                            <div class="col-sm-6">
                                <label class="form-control" name="returnType"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="currentRate">利率</label>
                            <div class="col-sm-6">
                                <label class="form-control" name="currentRate"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="totalRewardAmount">总利息</label>
                            <div class="col-sm-6">
                                <label class="form-control" name="totalRewardAmount"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="note">审核备注</label>
                            <div class="col-sm-6">
                                <textarea name="note" rows="4" cols="60"></textarea>
                            </div>
                        </div>
                    </fieldset>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-success btn_audit" value="5">审核通过</button>
                <button type="button" class="btn btn-warning btn_audit" value="6">审核拒绝</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
